<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>生成枚举的条目清单</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="class.unitenum.html">« UnitEnum</a></li>
      <li style="float: right;"><a href="class.backedenum.html">BackedEnum »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.unitenum.html">UnitEnum</a></li>
    <li>生成枚举的条目清单</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="unitenum.cases" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">UnitEnum::cases</h1>
  <p class="verinfo">(PHP 8 &gt;= 8.1.0)</p><p class="refpurpose"><span class="refname">UnitEnum::cases</span> &mdash; <span class="dc-title">生成枚举的条目清单</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-unitenum.cases-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><strong>UnitEnum::cases</strong></span>(): <span class="type">array</span></div>

  <p class="para rdfs-comment">
   该方法返回打包后的 array，以语法中的顺序，包含了枚举的所有条目。
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-unitenum.cases-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-unitenum.cases-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
  以语法中定义的顺序，返回该枚举中定义的所有条目数组。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-unitenum.cases-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-406">
   <p><strong>示例 #1 基本用法</strong></p>
   <div class="example-contents"><p>
   下例演示了如何返回枚举条目。
   </p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />enum&nbsp;Suit<br /></span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: #0000BB">Hearts</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: #0000BB">Diamonds</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: #0000BB">Clubs</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: #0000BB">Spades</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">Suit</span><span style="color: #007700">::</span><span style="color: #0000BB">cases</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程会输出：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
array(4) {
    [0]=&gt;
    enum(Suit::Hearts)
    [1]=&gt;
    enum(Suit::Diamonds)
    [2]=&gt;
    enum(Suit::Clubs)
    [3]=&gt;
    enum(Suit::Spades)
}
</pre></div>
   </div>
  </div>
 </div>


</div></div></div></body></html>